


import 'package:get/get.dart';
import 'package:xim/widget/dash_chat_2/dash_chat_2.dart';


/// 控制器
class ChatDetailPageController extends GetxController {

  final state =  ChatDetailPageState();

  /// 发送文件
  void sendImageMessage(){

  }

  /// 发送普通文本消息
  void sendTextMessage(String msg){
    state.messages.insert(0, ChatMessage(user: state.currUser, createdAt: DateTime.now()));
  }

  /// 发送视频文件
  void sendVideoMessage(String msg){
  }

  void sendMessage(ChatMessage message){
    state.messages.insert(0, message);
    update();
  }

}

/// state 数据
class ChatDetailPageState {

  /// 当前用户
  ChatUser currUser = ChatUser(
      id: '1',
      firstName: 'Charles',
      lastName: 'Leclerc',
      profileImage:
      "https://tupian.qqw21.com/article/UploadPic/2019-9/20199172252677674.jpg");

  /// 目标用户
  ChatUser user2 = ChatUser(
      id: '2',
      firstName: 'eeee',
      lastName: 'xeee',
      profileImage: "https://p.qqan.com/up/2019-6/2019061008021975853.jpg");

  /// 聊天数据
  final messages = <ChatMessage>[];
}